import os
import pyautogui
import time
import logging #日志模块，用于调试
#------------------------------------------------
pyautogui.PAUSE=1 #每执行一条pyautogui指令，暂停1s
pyautogui.FAILSAFE=True  #开启错误保险(鼠标移到左上角，退出脚本)
#-------------------------------------------------
ver='====MK 1.0======'
print(ver)
pyautogui.moveTo(16,754,duration=0.8)  #鼠标移动到win的开始菜单
pyautogui.click(button='left') #单击鼠标左键

pyautogui.moveTo(781,458,duration=0.8)  #鼠标移动画图应用图标
pyautogui.click(button='left') #单击鼠标左键

pyautogui.moveTo(578,422,duration=0.8)  #鼠标移动到画图应用内部
pyautogui.click(button='left') #单击鼠标左键，获得焦点

#------------下面进行绘图操作---------------------
distance=200
while distance>0:
    pyautogui.dragRel(distance,0,duration=0.4) #move right
    distance-=5
    pyautogui.dragRel(0,distance,duration=0.4) #move down
    distance-=5
    pyautogui.dragRel(-distance,0,duration=0.4) #move left
    distance-=5
    pyautogui.dragRel(0,-distance,duration=0.4) #move up
    distance-=5
    
pyautogui.mouseUp()  #释放鼠标按键
pyautogui.click(235,83,button='left') #直接单击保存键
pyautogui.click(569,464,button='left') #保存文件名

pyautogui.keyDown('backspace',0.3) 
pyautogui.keyUp('backspace',0.3)  #点击一次退格
pyautogui.keyDown('backspace',0.3) 
pyautogui.keyUp('backspace',0.3)  #点击一次退格
pyautogui.keyDown('backspace',0.3) 
pyautogui.keyUp('backspace',0.3)  #点击一次退格
pyautogui.keyDown('backspace',0.3) 
pyautogui.keyUp('backspace',0.3)  #点击一次退格

pyautogui.typewrite('PythonPic1')

pyautogui.click(904,538,button='left') #直接单击保存键
pyautogui.click(1236,86,button='left') #直接单击关闭键

